fix: remove default argument now
from _seconds_until_refresh
#356
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
_seconds_until_refresh
which is used for background refresh strategy(lazy refresh is unaffected!) should not have
now
as a default argumentdue to Python only evaluating default arguments once at function definition.
Problematic code:
alloydb-python-connector/google/cloud/alloydb/connector/refresh_utils.py
Lines 29 to 53 in 14d6b1c
Having
now
as a default argument means it is set once and then neveradjusted. So in subsequent calls to
_seconds_until_refresh
theduration
will just continue to grow larger and larger as it evaluates agains the same
now
The result of this means that
duration // 2
block is always being hit andwill continue to grow. It could grow to be greater than 3600 and lead to errors.